From: kfraser@localhost.localdomain Date: Tue, 1 Aug 2006 16:28:19 +0000 (+0100) Subject: [HVM][SVM] Change the calling convention for SVM VMMCALLs so X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15754^2~25 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=8e3af29104242a0b411be048a4455884cfca06dd;p=xen.git [HVM][SVM] Change the calling convention for SVM VMMCALLs so that they don't conflict with the hypercall calling convention. Signed-off-by: Steven Smith --- diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 702a988fab..4c4637dc58 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -31,7 +31,7 @@ #define ROMBIOS_PHYSICAL_ADDRESS 0x000F0000 /* invoke SVM's paged realmode support */ -#define SVM_VMMCALL_RESET_TO_REALMODE 0x00000001 +#define SVM_VMMCALL_RESET_TO_REALMODE 0x80000001 /* * C runtime start off @@ -133,15 +133,15 @@ cirrus_check(void) return inb(0x3C5) == 0x12; } -int -vmmcall(int edi, int esi, int edx, int ecx, int ebx) +int +vmmcall(int function, int edi, int esi, int edx, int ecx, int ebx) { int eax; __asm__ __volatile__( ".byte 0x0F,0x01,0xD9" : "=a" (eax) - : "a"(0x58454E00), /* XEN\0 key */ + : "a"(function), "b"(ebx), "c"(ecx), "d"(edx), "D"(edi), "S"(esi) ); return eax; @@ -200,7 +200,7 @@ main(void) if (check_amd()) { /* AMD implies this is SVM */ puts("SVM go ...\n"); - vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0); + vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0, 0); } else { puts("Loading VMXAssist ...\n"); memcpy((void *)VMXASSIST_PHYSICAL_ADDRESS, diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 9ee9ee5bf8..4490bd7f5f 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2349,33 +2349,41 @@ static int svm_do_vmmcall(struct vcpu *v, struct cpu_user_regs *regs) inst_len = __get_instruction_length(vmcb, INSTR_VMCALL, NULL); ASSERT(inst_len > 0); - /* VMMCALL sanity check */ - if (vmcb->cpl > get_vmmcall_cpl(regs->edi)) + if ( regs->eax & 0x80000000 ) { - printf("VMMCALL CPL check failed\n"); - return -1; - } - - /* handle the request */ - switch (regs->edi) - { - case VMMCALL_RESET_TO_REALMODE: - if (svm_do_vmmcall_reset_to_realmode(v, regs)) + /* VMMCALL sanity check */ + if ( vmcb->cpl > get_vmmcall_cpl(regs->edi) ) { - printf("svm_do_vmmcall_reset_to_realmode() failed\n"); + printf("VMMCALL CPL check failed\n"); return -1; } - - /* since we just reset the VMCB, return without adjusting the eip */ - return 0; - case VMMCALL_DEBUG: - printf("DEBUG features not implemented yet\n"); - break; - default: - break; - } - hvm_print_line(v, regs->eax); /* provides the current domain */ + /* handle the request */ + switch ( regs->eax ) + { + case VMMCALL_RESET_TO_REALMODE: + if ( svm_do_vmmcall_reset_to_realmode(v, regs) ) + { + printf("svm_do_vmmcall_reset_to_realmode() failed\n"); + return -1; + } + /* since we just reset the VMCB, return without adjusting + * the eip */ + return 0; + + case VMMCALL_DEBUG: + printf("DEBUG features not implemented yet\n"); + break; + default: + break; + } + + hvm_print_line(v, regs->eax); /* provides the current domain */ + } + else + { + hvm_do_hypercall(regs); + } __update_guest_eip(vmcb, inst_len); return 0; diff --git a/xen/include/asm-x86/hvm/svm/vmmcall.h b/xen/include/asm-x86/hvm/svm/vmmcall.h index 41c40473f9..7587bab7c6 100644 --- a/xen/include/asm-x86/hvm/svm/vmmcall.h +++ b/xen/include/asm-x86/hvm/svm/vmmcall.h @@ -23,11 +23,11 @@ #define __ASM_X86_HVM_SVM_VMMCALL_H__ /* VMMCALL command fields */ -#define VMMCALL_CODE_CPL_MASK 0xC0000000 -#define VMMCALL_CODE_MBZ_MASK 0x3FFF0000 +#define VMMCALL_CODE_CPL_MASK 0x60000000 +#define VMMCALL_CODE_MBZ_MASK 0x1FFF0000 #define VMMCALL_CODE_COMMAND_MASK 0x0000FFFF -#define MAKE_VMMCALL_CODE(cpl,func) ((cpl << 30) | (func)) +#define MAKE_VMMCALL_CODE(cpl,func) ((cpl << 29) | (func) | 0x80000000) /* CPL=0 VMMCALL Requests */ #define VMMCALL_RESET_TO_REALMODE MAKE_VMMCALL_CODE(0,1) @@ -38,7 +38,7 @@ /* return the cpl required for the vmmcall cmd */ static inline int get_vmmcall_cpl(int cmd) { - return (cmd & VMMCALL_CODE_CPL_MASK) >> 30; + return (cmd & VMMCALL_CODE_CPL_MASK) >> 29; } #endif /* __ASM_X86_HVM_SVM_VMMCALL_H__ */